package com.aegean.MonitorExamSYS.android.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.android.business.AndroidBusiness;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ExamineesPhotoForAndroid")
@Scope("prototype")
public class ExamineesPhotoForAndroid extends ActionSupport {
	private int position_Id;
	private String photoName;
	public int getPosition_Id() {
		return position_Id;
	}

	public void setPosition_Id(int position_Id) {
		this.position_Id = position_Id;
	}

	public String getPhotoName() {
		return photoName;
	}

	public void setPhotoName(String photoName) {
		this.photoName = photoName;
	}

	public InputStream getDownload() {
		try {
			String root = ServletActionContext.getServletContext().getRealPath(
					"/temp/" + position_Id);
			File photo = new File(root + "/" + photoName);
			InputStream in = new FileInputStream(photo);
			return in;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

}
